﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Slock.Utility
{
    /// <summary>
    /// Does various utility operations like creating wireframe meshes for bounding boxes and spheres.
    /// Defines methods for commonly used operations and various others
    /// </summary>
    public static class Helpers
    {
        /// <summary>
        /// Returns vertices and indices for a bounding box for debug mesh rendering
        /// </summary>
        /// <param name="primitive"></param>
        /// <param name="vertices"></param>
        /// <param name="indices"></param>
        /// <param name="color"></param>
        public static void BoundingBoxDebugMesh(BoundingBox primitive, out VertexPositionColor[] vertices, out short[] indices, Color color)
        {
            vertices = new VertexPositionColor[8];

            indices = new short[36];

            var corners = primitive.GetCorners();

            for (int vertex = 0; vertex < 8; vertex++)
                vertices[vertex] = new VertexPositionColor() { Position = corners[vertex], Color = color };

            indices = new short[] { 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 };
        }
    }
}
